
<h3>Administrateurs</h3>
<script src="pages_admin/adherents/adherents.js" type="text/javascript"></script>
<?php
	if($super_admin = $_SESSION['id'] == 1 ? 1 : 0) {
		echo '<p class="refresh"><a href="javascript:window.location.reload();">Actualiser la page</a></p>
			  <p class="add"><a href="javascript:void(0);" id="open_admin_add">Créer un administrateur ou modérateur</a></p>
			  <p class="delete"><a href="javascript:void(0);" id="open_admin_delete">Supprimer un administrateur ou modérateur</a></p>';
	}
?>
<table class="dataTable">
	<thead>
	<tr>
		<th>Nom</th>
		<th>Prénom</th>
		<th>E-mail</th>
		<th>Statut</th>
	</tr>
	</thead>
	<tbody>
<?php
$admins = member_get_list(ADMIN | MODO);

while ($row = mysql_fetch_assoc($admins)) {
	echo '
	<tr>
		<td>
			<a href="javascript:details('.$row['id'].');" title="Voir les détails">'.icon_tag('user').'</a>
			'.$row['name'].'
		</td>
		<td>'.$row['firstname'].'</td>
		<td>'.$row['email'].'</td>
		<td>';
			if($super_admin && $row['id'] != $super_admin) {
				echo '<img class="edit_status right" id="id_'.$row['id'].'" src="images/icons/pencil.png" alt="Edit" title="Modifier" />';
			}
			echo '<span style="color: '.$row['status_color'].'">'.$row['status_label'].'</span>';
			echo '
		</td>
	</tr>';
}
?>
	</tbody>
</table>

<div id="admin_add" class="hidden">
	<form method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>">
	<fieldset>
		<label for="name">Nom</label>
        <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />

		<label for="firstname">Prénom</label>
        <input type="text" name="firstname" id="firstname" class="text ui-widget-content ui-corner-all" />

		<label for="mail">Mail</label>
        <input type="text" name="mail" id="mail" class="text ui-widget-content ui-corner-all" />

        <label for="mdp1">Mot de passe</label>
        <input type="password" name="mdp1" id="mdp1" class="text ui-widget-content ui-corner-all" />

		<label for="mdp2">Confirmation mot de passe</label>
        <input type="password" name="mdp2" id="mdp2" class="text ui-widget-content ui-corner-all" />

		<p class="decalhautdouble alignleft">
		<span>Statut</span><br />
        <select name="status" id="status" class="ui-widget-content">
			<option value="-1"></option>
			<?php
			$statuses = member_status_list();
			while ($status = mysql_fetch_assoc($statuses)) {
				if ($status['code'] == 'ADMIN' || $status['code'] == 'MODERATOR') {
					echo '<option value="'.$status['code'].'">'.$status['label'].'</option>';
				}
			}
			?>
		</select>
		</p>
	</fieldset>
	</form>
	<div class="ajax"></div>
</div>

<div id="admin_delete" class="hidden">
	<form method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>">
	<fieldset>
		<p class="decalhautdouble alignleft">
		<span>Admin à supprimer</span><br />
        <select name="admins" id="admins" class="ui-widget-content">
			<option value="-1"></option>
			<?php
			$admins = member_get_list(ADMIN | MODO);
			while($admin = mysql_fetch_assoc($admins))
				if($admin['id'] != 1)
					echo '<option value="'.$admin['id'].'">'.$admin['firstname'].' '.$admin['name'].' &nbsp;( '.$admin['email'].' )</option>';
			?>
		</select>
		</p>
	</fieldset>
	</form>
	<div class="ajax"></div>
</div>

<script src="pages_admin/admin/_admin.js" type="text/javascript"></script>
